﻿#region Copyright

// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Collections.Generic;
using System.Xml.Serialization;
using DesignByContract;
using Majesty_of_Omega.Properties;

#endregion

namespace Majesty_of_Omega.Config
{

    /// <summary>
    /// The MusicPackTable.xml container class
    /// </summary>
    [XmlType(AnonymousType = true, Namespace = "http://master-of-omega/MusicPack.xsd")]
    [XmlRoot(Namespace = "http://master-of-omega/MusicPack.xsd", IsNullable = false)]
    public class MusicPack : Spreadsheet
    {
        /// <summary>
        /// Serverity of a situation report entry
        /// </summary>
        public enum TrackId
        {
            /// <summary>
            /// No track at all :-)
            /// </summary>
            None,
            /// <summary>
            /// Music in the title sequence
            /// </summary>
            TitleScreen,
            /// <summary>
            /// Music for the galaxy screen
            /// </summary>
            GalaxyScreen,
            /// <summary>
            /// Music for the system screen
            /// </summary>
            SystemScreen
        }

        /// <remarks/>
        [XmlElement("Track")]
        public List<MusicTrack> MusicPackTracks { get; set; }

        /// <summary>
        /// Gets the title screen track
        /// </summary>
        /// <value>The title screen.</value>
        public MusicTrack TitleScreenTrack
        {
            get
            {
                return GetTrack(TrackId.TitleScreen);
            }
        }

        /// <summary>
        /// Gets as <see cref="MusicTrack"/> identified by a <see cref="TrackId"/> value.
        /// </summary>
        /// <param name="trackId">The track id.</param>
        /// <returns>The track (and not null)</returns>
        public MusicTrack GetTrack(TrackId trackId)
        {
            var track = MusicPackTracks.Find(t => t.Id == trackId);
            Ensure.IsNotNull(track, string.Format(Resources.MusicPack_GetTrack_Not_track_with_track_id__0__found_, trackId));
            return track;
        }

    }

    /// <summary>
    /// An entry in the MusicPackTable
    /// </summary>
    [XmlType(AnonymousType = true, Namespace = "http://master-of-omega/MusicPack.xsd")]
    public class MusicTrack
    {
        /// <summary>
        /// The unique Type_ID of this MusicPack entry
        /// </summary>
        /// <value>The type_ ID.</value>
        /// <remarks/>
        [XmlAttribute]
        public MusicPack.TrackId Id { get; set; }

        /// <summary>
        /// Gets or sets the title filename
        /// </summary>
        /// <value>The title.</value>
        [XmlAttribute]
        public string Title { get; set; }
    }
}